﻿using Common.Base;

using GameCommon.Manager;
using GameCommon.ManagerInterfaces;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameGraphics.Components
{
    public class Highlight
    {
        private readonly Texture2D highlight;

        private readonly Texture2D highlightOwned;

        private readonly Color ownedColor = new Color(248, 193, 25);

        private bool isOwner;

        private bool isMouseOver;

        private bool isSelected;

        public Highlight()
        {
            this.highlight = Managers.ContentManager.GetBoardTexture2D("Border", 1);
            this.highlightOwned = Managers.ContentManager.GetBoardTexture2D("BorderOwned", 1);
            this.Dimension = new Dimension(new Position(), this.highlight);
        }

        public Dimension Dimension { get; set; }

        public int Layer { get; set; }

        public void Draw(IDrawingManager manager)
        {
            if (this.isOwner)
            {
                manager.Add(this.highlightOwned, this.Dimension.Rectangle, Color.White, this.Layer);
            }

            if (this.isMouseOver)
            {
                manager.Add(this.highlight, this.Dimension.Rectangle, Color.White, this.Layer);
                return;
            }

            if (this.isSelected)
            {
                manager.Add(this.highlight, this.Dimension.Rectangle, Color.LimeGreen, this.Layer);
            }
        }

        public void Update(bool owner, bool selected, bool mouseOver)
        {
            this.isOwner = owner;
            this.isMouseOver = mouseOver;
            this.isSelected = selected;
        }
    }
}